import random
import time


again = True
while again:
    ans = random.randint(1, 100)
    print('欢迎进入猜数字游戏，答案是1到100之前的数字')
    max_guess = 8
    count = 0

    begin = time.time()

    while count < max_guess:
        count += 1
        print(f'第{count}轮')
        guess = int(input('猜猜？'))
        if guess == ans:
            print('猜对了！人生赢家！')
            break
        elif guess > ans:
            print('太大了！')
        elif guess < ans:
            print('太小了')
    else:
        print('超出猜测次数')

    end = time.time()
    print(f'用时：{end-begin}')
    print('\n回车重新开始游戏，输入任意内容结束游戏')
    if len(input()) > 0:
        again = False
        print('游戏结束')
